package cn.com.io.stream;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * Created by Administrator on 2015/12/9.
 */
public class FileOutputStreamTest {
    public static void main(String[] args) throws IOException {
        FileInputStream  fis = null;
        FileOutputStream fos = null;
        try {
            fis = new FileInputStream(new File(System.getProperty("user.dir") + "\\src\\cn\\com\\io\\stream\\FileOutputStreamTest.java"));//创建字节输入流
            fos = new FileOutputStream(new File("./FileOutputStreamTestCopy.java"));//创建字节输出流

            byte[] buf = new byte[32];
            int hasRead = 0;
            while((hasRead = fis.read(buf)) > 0){
                fos.write(buf,0,hasRead);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (fis != null ){
                //关闭文件输入流
                fis.close();
            }
            if (fos != null ){
                //关闭文件输出流
                fos.close();
            }
        }
    }
}
